/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

/**
 * Class that controls that traffic lights used in both the Gui and text version of the simulators
 * @author Luke
 */
public class Traffic_Lights {

    private boolean up_Lights = false; //Setup light vallues
    private String v_Lights = "Red";
    private String h_Lights = "Red";
    private int lights_Counter = 0;
    private int numVStreet = 0;

    /**
     * Constructor method for the traffic lights, sets up values and turns lights on
     * @param numVStreet Used to determine light cycle
     */
    public Traffic_Lights(int numVStreet) {
        this.numVStreet = numVStreet;
        changeState();
    }

    /**
     * Method used to toggle the light phasing.
     */
    public void changeState() {
        up_Lights = !up_Lights; //toggle the boolean value
        if (up_Lights) { //if true
            v_Lights = "Green";
            h_Lights = "Red";
        } else {
            v_Lights = "Red";
            h_Lights = "Green";
        }
    }

    /**
     * Getter method for the horizontal lights
     * @return The phasing of the horizontal traffic lights
     */
    public String getH_Lights() {
        return h_Lights;
    }

    /**
     * Getter method for the vertical lights
     * @return The phasing of the vertical traffic lights
     */
    public String getV_Lights() {
        return v_Lights;
    }

    /**
     * Method for the all red phasing to begin.
     */
    public void noCars(){
        v_Lights = "Red";
        h_Lights = "Red";
    }

    /**
     * Method that controls the light phasing based on the number of times cars moves are made.
     */
    public void incrementCount() {

        if (lights_Counter == 10) {
                v_Lights = "Green";
            } else if (lights_Counter == 15) {
                v_Lights = "Red";
            } else if (lights_Counter == 19) {
                h_Lights = "Green";
            } else if (lights_Counter == 24) {
                h_Lights = "Red";
                lights_Counter = 6; //reset the counter
            }

        lights_Counter++;

    }

    }
